package cn.sdormitory.controller.report;

import cn.sdormitory.common.api.CommonPage;
import cn.sdormitory.common.api.CommonResult;
import cn.sdormitory.report.service.DormitoryStatisticsService;
import cn.sdormitory.report.vo.DormitoryStatisticsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @创建人：zhouyang
 * @创建时间：2021/12/6 22:14
 * @version：V1.0
 */
@RestController
@Api(tags = "Report-AttenceStatistics=> 宿舍人数统计")
@RequestMapping("/report/dormitorystatistics")
public class DormitoryStatisticsController {
    @Autowired
    private DormitoryStatisticsService dormitoryStatisticsService;

    @ApiOperation("list => 查询报修统计列表")
    @PreAuthorize("@ss.hasPermi('report:dormitorystatistics:list')")
    @GetMapping(value = "/list")
    public CommonResult<CommonPage<DormitoryStatisticsVo>> list(@RequestParam Map<String, Object> params) {
        List<DormitoryStatisticsVo> dormitoryStatisticsVos = dormitoryStatisticsService.getDorStaList((String)params.get("buildingNo"),(String)params.get("storey"),(String)params.get("dormitoryNo"),Integer.parseInt((String)params.get("pageNum")),Integer.parseInt((String)params.get("pageSize")));
        CommonPage<DormitoryStatisticsVo> commonPage = new CommonPage<DormitoryStatisticsVo>();
        commonPage.setList(dormitoryStatisticsVos);
        Long count=dormitoryStatisticsService.getDorStaListCount((String)params.get("buildingNo"),(String)params.get("storey"),(String)params.get("dormitoryNo"));
        commonPage.setTotal(count);
        return CommonResult.success(commonPage);

    }
}
